import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import schoolboy from '../views/schoolboy.vue'

Vue.use(VueRouter)
Vue.use(Vuex)

const routes = [{
        path: '/',
        redirect: "/schoolboy"
    },
    {
        path: "/userInfo",
        name: "userInfo",
        component: () =>
            import ("../views/userinfo.vue"),
        beforeEnter: (to, from, next) => {
            let login = window.localStorage.getItem("token");
            // 判断没有值
            if (!login) {
                next("/login");
                return
            } else {
                next();
            }
        }
    },
    {
        path: '/schoolboy',
        name: 'schoolboy',
        component: schoolboy
    },
    {
        path: '/girlstudent',
        name: 'girlstudent',
        component: () =>
            import ('../views/girlstudent.vue')
    },
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('../components/base/login.vue')
    },
    {
        path: '/cover',
        name: 'cover',
        component: () =>
            import ('../views/cover.vue')
    },
    {
        path: '/lightnovel',
        name: 'lightnovel',
        component: () =>
            import ('../views/lightnovel.vue')
    },
    {
        path: '/more',
        name: 'more',
        component: () =>
            import ('../views/more.vue')
    },
    {
        path: '/bookdetails',
        name: 'bookdetails',
        component: () =>
            import ('../components/base/bookdetails.vue')
    },
    {
        path: '/classification',
        name: 'classification',
        component: () =>
            import ('../views/classification.vue')
    },
    {
        path: '/rankinglist',
        name: 'rankinglist',
        component: () =>
            import ('../views/rankinglist.vue')
    },
    {
        path: '/end',
        name: 'end',
        component: () =>
            import ('../views/end.vue')
    },
    {
        path: '/okami',
        name: 'okami',
        component: () =>
            import ('../views/okami.vue')
    },
    {
        path: '/search',
        name: 'search',
        component: () =>
            import ('../views/search.vue')
    },
    {
        path: '/help',
        name: 'help',
        component: () =>
            import ('../views/help.vue')
    },
    {
        path: '/grade',
        name: 'grade',
        component: () =>
            import ('../views/grade.vue')
    },
    {
        path: '/member',
        name: 'member',
        component: () =>
            import ('../views/member.vue')
    },
    {
        path: '/news',
        name: 'news',
        component: () =>
            import ('../views/news.vue')
    },
    {
        path: '/recharge',
        name: 'recharge',
        component: () =>
            import ('../views/recharge.vue')
    },
    {
        path: '/author',
        name: 'author',
        component: () =>
            import ('../views/author.vue')
    },
    {
        path: '/novelcontent',
        name: 'novelcontent',
        component: () =>
            import ('../components/base/novelcontent.vue')
    },
    {
        path: '/fanlist',
        name: 'fanlist',
        component: () =>
            import ('../views/fanlist.vue')
    },
    {
        path: '/bookshelf',
        name: 'bookshelf',
        component: () =>
            import ('../views/bookshelf.vue')
    },
    //   {
    //     path: '/about',
    //     name: 'About',
    //     // route level code-splitting
    //     // this generates a separate chunk (about.[hash].js) for this route
    //     // which is lazy-loaded when the route is visited.
    //     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    //   }
]

const router = new VueRouter({
    routes
})

export default router